package com.hlcl.huaji.ctrl.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.elcl.adapter.AbViewHolder;
import com.elcl.adapter.BaseLVAdapter;
import com.elcl.support.userage.domain.BaseSimpleItem;
import com.hlcl.huaji.R;

import java.util.List;

/**
 * Created by lichunlin on 2018/5/23.
 * 个人中心-订单类型
 */

public class MineOrderAdapter extends BaseLVAdapter<BaseSimpleItem> {

    public MineOrderAdapter(List<BaseSimpleItem> list, int idLayout) {
        super(list, idLayout);
    }

    private int ingNumber;//处理中订单的数量

    public void setIngNumber(int ingNumber) {
        this.ingNumber = ingNumber;
    }

    @Override
    public View getItemView(int position, View convertView, ViewGroup parent) {
        ImageView img_title = (ImageView) AbViewHolder.getView(convertView, R.id.img_title);
        TextView tv_title = (TextView) AbViewHolder.getView(convertView, R.id.tv_title);
        TextView tv_number = (TextView) AbViewHolder.getView(convertView, R.id.tv_number);

        BaseSimpleItem baseSimpleItem = list.get(position);
        if (null != baseSimpleItem) {
            img_title.setBackgroundResource(baseSimpleItem.getImg_recourse());
            tv_title.setText(baseSimpleItem.getContent());
            if (position == 2) {
                if (0 != ingNumber) {
                    tv_number.setText(ingNumber+"");
                    tv_number.setVisibility(View.VISIBLE);
                } else {
                    tv_number.setVisibility(View.GONE);
                }
            } else {
                tv_number.setVisibility(View.GONE);
            }
        }
        return convertView;
    }
}
